package com.test.servlet;

import java.io.IOException;
import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import com.test.service.IEmployeeService;
import com.test.service.impl.EmployeeServiceImpl;


@WebServlet("/DeleteEmployeeServlet")
public class DeleteEmployeeServlet extends HttpServlet {
	
	protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		// TODO Auto-generated method stub
		request.setCharacterEncoding("utf-8");
		response.setCharacterEncoding("utf-8");
		response.setContentType("text/html; charset=UTF-8");
		
		int id=Integer.parseInt(request.getParameter("id"));
		IEmployeeService employeeService=new EmployeeServiceImpl();
		boolean result=employeeService.deleteEmployee(id);
		if (result) {
			//response.getWriter().println("删除成功！");
			//删除完毕后重新调入到首页
			response.sendRedirect("QueryAllEmployeeServlet");
		} else {
			response.getWriter().println("删除失败！");
		}
	}

	
	protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		// TODO Auto-generated method stub
		doGet(request, response);
	}

}
